CREATE TABLE [dbo].[tb_RegimenDeSuplencias]
(
[idRegimenSuplencia] [int] NOT NULL IDENTITY(1, 1),
[Descripcion] [varchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL
) ON [PRIMARY]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE TRIGGER [dbo].[updatetb_RegimenDeSuplencias] ON [dbo].[tb_RegimenDeSuplencias]
 FOR UPDATE AS 
 IF (update(idRegimenSuplencia)) begin 
	 SELECT * FROM inserted 
	 IF @@ROWCOUNT = 1 begin 
		 UPDATE tb_FuncionesLUI
		 SET RegimenSuplencias = (SELECT idRegimenSuplencia FROM inserted)
		 WHERE tb_FuncionesLUI.RegimenSuplencias = (SELECT idRegimenSuplencia FROM deleted)
		 UPDATE tb_Plazas
		 SET RegimenSuplencias = (SELECT idRegimenSuplencia FROM inserted)
		 WHERE tb_Plazas.RegimenSuplencias = (SELECT idRegimenSuplencia FROM deleted)
		 UPDATE tb_AperturasDeReestructura
		 SET RegimenSuplencias = (SELECT idRegimenSuplencia FROM inserted)
		 WHERE tb_AperturasDeReestructura.RegimenSuplencias = (SELECT idRegimenSuplencia FROM deleted)
	end  ELSE begin 
		 ROLLBACK TRANSACTION 
 end 
 end
GO
ALTER TABLE [dbo].[tb_RegimenDeSuplencias] ADD CONSTRAINT [PK_tb_RegimenDeSuplencias] PRIMARY KEY NONCLUSTERED  ([idRegimenSuplencia]) ON [PRIMARY]
GO
